class Solution(object):
    def lengthOfLongestSubstring(self, s):
        """
        :type s: str
        :rtype: int
        """
        alpha = [-1 for _ in range(256)]
        maxLength = 0
        for i in range(len(s)):
            c = s[i]
            if alpha[ord(c)]!=-1:
                length = 0
                oldIndex=alpha[ord(c)]
                for j in range(len(alpha)):
                    if alpha[j]!=-1:
                        length+=1
                    if alpha[j]<=oldIndex:
                        alpha[j]=-1
                maxLength = max(maxLength, length)
            alpha[ord(c)]=i
        
        length = 0
        for j in range(len(alpha)):
            if alpha[j]!=-1:
                length+=1
        maxLength = max(maxLength, length)

        return maxLength

print(Solution().lengthOfLongestSubstring("dvdf"))